package cn.catsdad.controller;

import cn.catsdad.base.controller.FrameController;
import cn.catsdad.base.web.HttpResponse;
import cn.catsdad.service.api.LoginService;
import cn.catsdad.vo.LoginParams;
import cn.catsdad.vo.ResponseUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录controller
 *
 * @author xuyonglong
 * @version V1.0 2023/4/20
 */
@RestController
@RequestMapping("/api/login")
public class LoginController extends FrameController {

    private LoginService loginService;

    /**
     * 登录接口
     *
     * @param loginParams 登陆参数
     * @return token
     */
    @PostMapping
    public HttpResponse<ResponseUser> login(@RequestBody LoginParams loginParams) {
        return new HttpResponse<ResponseUser>().setData(loginService.login(loginParams));
    }

    @Autowired
    public void setLoginService(LoginService loginService) {
        this.loginService = loginService;
    }
}
